/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.bff.engine.core.action.delete;

import static com.inspur.edp.bff.engine.core.action.BffEngineAssemblerBase.getActions;

import com.inspur.edp.bff.api.manager.context.DeleteChildContext;
import com.inspur.edp.bff.spi.action.delete.AbstractDeleteAction;
import com.inspur.edp.bff.spi.action.delete.AbstractDeleteChildAction;
import com.inspur.edp.bff.spi.action.delete.AfterDeleteAction;
import com.inspur.edp.bff.spi.action.delete.BeforeDeleteAction;
import com.inspur.edp.bff.spi.action.delete.DefaultDeleteAction;
import com.inspur.edp.bff.spi.action.multidelete.AbstractMultiDeleteAction;
import com.inspur.edp.bff.spi.action.multidelete.AfterMultiDeleteAction;
import com.inspur.edp.bff.spi.action.multidelete.BeforeMultiDeleteAction;
import com.inspur.edp.bff.spi.action.multidelete.DefaultMultiDeleteAction;
import com.inspur.edp.bff.spi.assembler.AbstractExtendDeleteAssembler;
import com.inspur.edp.bff.spi.assembler.AbstractExtendDeleteChildAssembler;
import com.inspur.edp.formserver.viewmodel.GspViewModel;
import com.inspur.edp.formserver.viewmodel.collection.VMActionCollection;
import com.inspur.edp.formserver.viewmodel.common.InternalExtendActionUtil;
import java.util.ArrayList;

public class BffEngineDeleteChildAssembler extends AbstractExtendDeleteChildAssembler {

  private GspViewModel vo;

  private BffEngineDeleteChildAssembler(GspViewModel vo) {
    this.vo = vo;
  }

  public static BffEngineDeleteChildAssembler build(GspViewModel vo) {
    VMActionCollection actions = vo.getDataExtendInfo().getDeleteChildActions();
    if (actions == null || actions.isEmpty()) {
      return null;
    }
    return new BffEngineDeleteChildAssembler(vo);
  }

//  @Override
//  protected ArrayList<BeforeDeleteAction> getBeforeDeleteActions(DeleteChildContext DeleteChildContext) {
//    VMActionCollection actions = vo.getDataExtendInfo().getBeforeDeleteActions();
//    return getActions(BeforeDeleteAction.class, actions, getParamTypes(),
//        getParamValues(DeleteChildContext), null, null);
//  }

  @Override
  protected ArrayList<AbstractDeleteChildAction> getDeleteActions(DeleteChildContext DeleteChildContext) {
    VMActionCollection actions = vo.getDataExtendInfo().getDeleteChildActions();
    return getActions(AbstractDeleteChildAction.class, actions, getParamTypes(),
        getParamValues(DeleteChildContext), null, null);
  }
//
//  @Override
//  protected ArrayList<AfterDeleteAction> getAfterDeleteActions(DeleteChildContext DeleteChildContext) {
//    VMActionCollection actions = vo.getDataExtendInfo().getAfterDeleteActions();
//    return getActions(AfterDeleteAction.class, actions, getParamTypes(),
//        getParamValues(DeleteChildContext), null, null);
//  }
//
//  @Override
//  protected ArrayList<BeforeMultiDeleteAction> getBeforeMultiDeleteActions(
//      DeleteChildContext delContext) {
//    VMActionCollection actions = vo.getDataExtendInfo().getBeforeMultiDeleteActions();
//    return getActions(BeforeMultiDeleteAction.class, actions, getParamTypes(),
//        getParamValues(delContext), null, null);
//  }
//
//  @Override
//  protected ArrayList<AbstractMultiDeleteAction> getMultiDeleteActions(DeleteChildContext delContext) {
//    VMActionCollection actions = vo.getDataExtendInfo().getMultiDeleteActions();
//    return getActions(
//        AbstractMultiDeleteAction.class,
//        actions,
//        getParamTypes(),
//        getParamValues(delContext),
//        new DefaultMultiDeleteAction(delContext),
//        InternalExtendActionUtil.MultiDeleteActionId);
//  }
//
//  @Override
//  protected ArrayList<AfterMultiDeleteAction> getAfterMultiDeleteActions(DeleteChildContext delContext) {
//    VMActionCollection actions = vo.getDataExtendInfo().getAfterMultiDeleteActions();
//    return getActions(AfterMultiDeleteAction.class, actions, getParamTypes(),
//        getParamValues(delContext), null, null);
//  }

  private ArrayList<Class> getParamTypes() {
    ArrayList<Class> paramTypes = new ArrayList<>();
    paramTypes.add(DeleteChildContext.class);
    return paramTypes;
  }

  private ArrayList<Object> getParamValues(DeleteChildContext DeleteChildContext) {
    ArrayList<Object> values = new ArrayList<>();
    values.add(DeleteChildContext);
    return values;
  }
}
